<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.model.Payment"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><%=UserUtil.getCurrentMenuItemName() %></title>
	<script type="text/javascript">
	<!--	
	$(document).ready(function() {	
		$("[id^='viewPaymentImg-']").click(function() {
			var uploadFilePk = this.id.substring(15);
			doQueryPaymentsAction(uploadFilePk);
			
		});
	});

	function doQueryAction()
	{
		$.ajax({url : "<c:url value='/ajax/Soez2004.action'/>",
			async : true,
			type : 'POST',
			data : $("#queryListFrom").serialize(),
			dataType : 'html',
			success : function(data, textStatus, XMLHttpRequest){
					$("#paymentListDiv").html(data);
				},
			error : function(XMLHttpRequest, textStatus, errorThrown){
				$("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
				$("#ajaxErrorMessageDiv" ).dialog( "destroy" );
				$("#ajaxErrorMessageDiv" ).dialog({  
					title:'系統錯誤' 
					,width: 600
					, resizable: false
					, modal: true
					, buttons: {
						Ok: function() {
							$( this ).dialog( "close" );
						}
					}
				});
				},
			complete: function(XMLHttpRequest, textStatus){
				$("#paymentListDiv").fadeTo("slow", 1);
				closeWaitingDialog();
			}
		});
	}
	
	function doQueryPaymentsAction(paymentPk)
	{
		$('#hidden\\.qryPayment\\.paymentPk').val(paymentPk);

		waitingDialog({});
		
		$.ajax({url : "<c:url value='/ajax/Soez2004.action'/>",
			async : true,
			type : 'POST',
			data : $("#queryHiddenFrom").serialize(),
			dataType : 'html',
			success : function(data, textStatus, XMLHttpRequest){
					$("#paymentsItemDiv").html(data);
				},
			error : function(XMLHttpRequest, textStatus, errorThrown){
				$("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
				$("#ajaxErrorMessageDiv" ).dialog( "destroy" );
				$("#ajaxErrorMessageDiv" ).dialog({  
					title:'系統錯誤' 
					,width: 600
					, resizable: false
					, modal: true
					, buttons: {
						Ok: function() {
							$( this ).dialog( "close" );
						}
					}
				});
				},
			complete: function(XMLHttpRequest, textStatus){
				closeWaitingDialog();
			}
		});
	}
	
	function doPaymentsConfirmAction(paymentStatus)
	{
		var isDoComfirm = false;
		$('#confirmHiddenFrom input:checkbox.chk').each(function(){               
        	if ( $(this).attr('checked') ){
        		isDoComfirm = true;
        	}
       	});
		
		if(isDoComfirm){
			$('#hidden\\.qryPayment\\.paymentStatus').val(paymentStatus);
			waitingDialog({});
			
			$.ajax({url : "<c:url value='/ajax/Soez2004.action'/>",
				async : true,
				type : 'POST',
				data : $("#confirmHiddenFrom").serialize(),
				dataType : 'html',
				success : function(data, textStatus, XMLHttpRequest){
						$("#paymentListDiv").html(data);
					},
				error : function(XMLHttpRequest, textStatus, errorThrown){
					$("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
					$("#ajaxErrorMessageDiv" ).dialog( "destroy" );
					$("#ajaxErrorMessageDiv" ).dialog({  
						title:'系統錯誤' 
						,width: 600
						, resizable: false
						, modal: true
						, buttons: {
							Ok: function() {
								$( this ).dialog( "close" );
							}
						}
					});
					},
				complete: function(XMLHttpRequest, textStatus){
					closeWaitingDialog();
					$("#paymentListDiv").fadeTo("hide", 1);
				}
			});
	
		}else{
			$("#ajaxErrorMessageDiv").html("至少選擇一筆");
                    $("#ajaxErrorMessageDiv" ).dialog( "destroy" );
                    $("#ajaxErrorMessageDiv" ).dialog({  
                        title:'錯誤訊息' 
                        ,width: 600
                        , resizable: false
                        , modal: true
                        , buttons: {
                            Ok: function() {
                                $( this ).dialog( "close" );
                            }
                        }
                    });
                    return false;
		}
	}
	
	function doCheckAll(){
		$('#confirmHiddenFrom input:checkbox.chk').each(function(){              
        $(this).attr("checked", true);
       });
	}
	
	function undoCheckAll(){
		$('#confirmHiddenFrom input:checkbox.chk').each(function(){               
        $(this).attr("checked", false);
       });
	}
	//-->
	</script>
</head>
<body>
<div id="mainAreaCT">
		<jsp:include page="/includes/path.jsp"/>
		<jsp:include page="/includes/subMenu.jsp"/>
		
		
		
<stripes:form id="queryListFrom" beanclass="com.feib.soeasy.action.Soez2004ActionBean" 
			method="post" onsubmit="javascript: return false;">
			<input type="hidden" id="method" name="doAjaxQuery"/>
</stripes:form>
<div id="paymentListDiv" style="display: none;">
</div>

<!-- 繳費總覽查詢結果  -->
<div id="paymentsItemDiv" style="display: none;">
</div>
	
<div id="queryPaymentHiddenFormDiv" style="display: none;">
	<stripes:form id="queryHiddenFrom" beanclass="com.feib.soeasy.action.Soez2004ActionBean" 
		method="post" onsubmit="javascript: return false;">
		
		<stripes:hidden id="hidden.qryPayment.paymentPk" name="qryPayment.paymentPk"/>			
		<input type="hidden" id="method" name="doAjaxQueryPayments"/>
	</stripes:form>
</div>

<!-- Message -->
<div id="ajaxErrorMessageDiv" style="display: none;"></div>

</div>


<script type="text/javascript">
<!--    
doQueryAction();
//-->
</script>

</body>
</html>